<template>
	<view class="container">
		<view class="head">
			<swiper autoplay="auto" :circular="true" class="swiper" duration="500" :indicatorActiveColor="color"
				indicatorColor="#ccc" :indicatorDots="true" interval="5000">
				<!--style="300rpx"-->
				<swiper-item v-for="(item, index) in imgArray" :key="index">
					<image @tap="jumps" :data-appid="item.appid" :data-id="item.id" :data-name="item.title" :data-src="item.src"
						:data-type="item.item" :data-wb_src="item.src2" mode="aspectFill" :src="item.logo"></image>
				</swiper-item>
			</swiper>
		</view>
		<view class="nav ba_f mar_t">
			<swiper autoplay="auto" :circular="true" class="swiper" duration="500" :indicatorActiveColor="color"
				indicatorColor="#f7f7f7" :indicatorDots="false" interval="5000" style="height: 80rpx">
				<swiper-item v-for="(item, index) in nav_array" :key="index" style="display: flex">
					<view class="dis_in nav_li all">
						<view class="t_c fon_28 gobyndsingle text-center">全部</view>
					</view>
					<view @tap="nav_child" class="dis_in nav_li" :data-id="item.id" v-for="(item, index1) in item" :key="index1">
						<view class="t_c fon_28 gobyndsingle text-center">{{ item.name }}</view>
					</view>
				</swiper-item>
			</swiper>
		</view>
		<view class="mar_t">
			<view @tap="goindex" class="shop_list pa bor_bottom" :data-id="item.id" :data-storeid="item.store_id"
				v-for="(item, index) in group_list" :key="index">
				<view class="dis_in">
					<image mode="aspectFill" :src="item.logo"></image>
				</view>

				<view class="dis_in">
					<view class="store-name gobyndsingle" style="font-weight: bold">{{item.name}}</view>
					<view class="fon_24 color_6 gobyndsingle mdtp">
						<!-- <image mode="aspectFill" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/tabdn.png"></image>
						<view style="line-height: 50rpx">{{
              item.store_name
            }}</view> -->
						<image mode="aspectFill" :src="item.logo"></image>
						<image mode="aspectFill" :src="item.logo"></image>
						<text>{{item.num}}人已拼</text>
					</view>
					<view class="btn-option">
						<view class="price">
							<view class="top">
								<text>{{ item.people }}人团￥</text>
								<text>{{ item.pt_price }}</text>
							</view>
							<view class="bottom">
								单买价¥{{ item.y_price }}
							</view>
						</view>
						<text class="fon_28 mar_l" :style="
                'background:#FE544E;color:#fff;padding:10rpx 30rpx;float:right;border-radius: 50rpx;font-size: 26rpx'
              ">立即开团</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import cardlist from '@/ymq_canyino2o/dist/cardlist/index'
	import gettel from '@/ymq_canyino2o/dist/gettel/index'
	var app = getApp()
	export default {
		components: {
			cardlist,
			gettel
		},
		data() {
			return {
				page: 1,
				group_list: [],
				store_id: '',
				store_logo: '',
				imgArray: '',
				nav_array: '',
				height: '',
				color: ''
			}
		},
		onLoad: function(t) {
			app.globalData.setNavigationBarColor(this)
			uni.setNavigationBarTitle({
				title: t.title
			})
			this.setData({
				store_id: t.id,
				store_logo: t.store_logo
			})
			this.reload()
		},
		onReady: function() {},
		onShow: function() {
			this.refresh()
		},
		onHide: function() {},
		onUnload: function() {},
		onPullDownRefresh: function() {},
		onReachBottom: function() {
			this.reload()
		},
		onShareAppMessage: function() {},
		methods: {
			refresh: function(t) {
				var that = this
				app.globalData.util.request({
					url: 'entry/wxapp/Ad',
					cachetime: '0',
					data: {
						type: 9
					},
					success: function(t) {
						console.log('轮播图列表', t)
						that.setData({
							imgArray: t.data
						})
					}
				})
				app.globalData.util.request({
					url: 'entry/wxapp/GroupType',
					cachetime: '0',
					success: function(t) {
						console.log('分类列表', t)
						if (5 < t.data.length) {
							var a = 340
						} else {
							a = 170
						}
						for (var e = [], o = 0, r = t.data.length; o < r; o += 10) {
							e.push(t.data.slice(o, o + 10))
						}
						that.setData({
							nav_array: e,
							height: a
						})
					}
				})
			},

			reload: function(t) {
				var that = this
				var e = that.page
				var o = that.group_list
				app.globalData.util.request({
					url: 'entry/wxapp/GroupGoods',
					cachetime: '0',
					data: {
						store_id: '',
						type_id: '',
						page: e,
						display: 1
					},
					success: function(t) {
						console.log('商品列表', t)
						if (0 < t.data.length) {
							o = o.concat(t.data)
							that.setData({
								group_list: o,
								page: e + 1
							})
						}
					}
				})
			},

			jumps: function(t) {
				var a = t.currentTarget.dataset.id
				var e = t.currentTarget.dataset.name
				var o = t.currentTarget.dataset.appid
				var r = t.currentTarget.dataset.src
				var n = t.currentTarget.dataset.wb_src
				var i = t.currentTarget.dataset.type
				console.log(a, e, o, r, n, i)
				if (1 == i) {
					console.log(r)
					uni.navigateTo({
						url: r
					})
				} else {
					if (2 == i) {
						uni.setStorageSync('vr', n)
						uni.navigateTo({
							url: '../car/car'
						})
					} else {
						if (3 == i) {
							uni.navigateToMiniProgram({
								appId: o
							})
						}
					}
				}
			},

			nav_child: function(t) {
				uni.navigateTo({
					url: 'list?id=' +
						t.currentTarget.dataset.id +
						'&store_id=&store_logo=' +
						this.store_logo +
						'&display=1'
				})
			},

			goindex: function(t) {

				this.checkLogin()

				uni.navigateTo({
					url: 'index?id=' +
						t.currentTarget.dataset.id +
						'&store_id=' +
						t.currentTarget.dataset.storeid +
						'&store_logo=' +
						this.store_logo
				})
			}
		}
	}
</script>
<style scoped>
	@import './group.css';
</style>